<?php
/*
 *   This file is part of verbum.
 *
 *   poat is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   poat is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with poat.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * 	 Copyright (c) 2008 Sergio Gabriel Teves <gabriel.sgt at gmail.com>
 */

$userid = $param['userid'];
$u = new user;
$u->userid=$userid;
$loader->get($u);

$profiles = array();
foreach ($GROUP_LIST as $grp) {
	$pr = array();
	if (($CURRENT_USER->groupid != GROUP_ADMIN and $grp != GROUP_ADMIN) or $CURRENT_USER->groupid == GROUP_ADMIN) {
		$pr['name']=$grp;
		$pr['value']=s($DEF_TRANS[$grp]);
		array_push($profiles,$pr);
	}
}

$jprofiles = jsonArray($profiles,"name","value");

if ($CURRENT_USER->groupid == GROUP_ADMIN) {
	$team = new team;
	$team->status=STATUS_ACTIVE;
	$list = $loader->loadListBy($team,$team->listByStatus());
	$tlist = jsonArray($list,"id","name");
}

?>
{
    xtype : "fieldset",
    autoHeight : true,
    labelWidth: 70,
    items : [
    {
    xtype : "textfield",
    fieldLabel : "<?php echo s("User",null,true); ?>",
    value: "<?php echo $u->userid; ?>",
    name : "userid",
    readOnly: <?php echo ($CURRENT_USER->groupid == GROUP_ADMIN ? "false" : "true"); ?>
  	},
  	{
    xtype : "textfield",
	cls : "x-hide-display",
	hideLabel: true,
    name : "ouserid",
	value: "<?php echo $u->userid; ?>",
  	},
    {	
	xtype:"combo",
	fieldLabel: "<?php echo s("Profile",null,true); ?>",
	hiddenName:"groupid",
	value:"<?php echo $u->groupid; ?>",
	allowBlank: false,
	blankText:"<?php echo s("Please, select a profile.",null,true); ?>",
	forceSelection: true,
	triggerAction: 'all',
   	store: <?php echo $jprofiles ?>
    }
<?php 
	if ($CURRENT_USER->groupid == GROUP_ADMIN) {
?>
	,{
        xtype:"combo",
        fieldLabel:"<?php echo s("Team",null,true); ?>",
        hiddenName:"teamid",
        value:"<?php echo $u->teamid; ?>",
        allowBlank: false,
        blankText:"<?php echo s("Please, select a team.",null,true); ?>",
        store: <?php echo $tlist ?>,
        forceSelection: true,
        triggerAction: 'all',
      }
<?php } ?>
    ]
}